import request from './axios'

// 获取所有科室
export const getAllDepartments = () => {
  return request.get('/departments')
}

// 根据ID获取科室
export const getDepartmentById = (id) => {
  return request.get(`/departments/${id}`)
}

// 新增科室
export const addDepartment = (data) => {
  return request.post('/departments', data)
}

// 更新科室
export const updateDepartment = (id, data) => {
  return request.put(`/departments/${id}`, data)
}

// 删除科室
export const deleteDepartment = (id) => {
  return request.delete(`/departments/${id}`)
}

// 批量删除科室
export const batchDeleteDepartments = (ids) => {
  return request.delete('/departments/batch', {
    data: ids
  })
}

// 分页查询科室
export const getDepartmentsByPage = (pageNum, pageSize) => {
  return request.get('/departments/page', {
    params: {
      pageNum,
      pageSize
    }
  })
}

// 根据条件查询科室
export const searchDepartments = (condition) => {
  return request.post('/departments/search', condition)
}

// 统计科室总数
export const countDepartments = () => {
  return request.get('/departments/count')
}

// 根据条件统计科室数量
export const countDepartmentsByCondition = (condition) => {
  return request.post('/departments/count', condition)
}

// 批量新增科室
export const batchAddDepartments = (list) => {
  return request.post('/departments/batch', list)
}